import imp
from time import sleep
from selenium import webdriver
from selenium.webdriver import ActionChains

driver = webdriver.Chrome()
driver.implicitly_wait(5)
driver.maximize_window()
driver.get("https://www.baidu.com")

ele = driver.find_element("xpath", '//*[@id="s-usersetting-top"]')
ActionChains(driver).move_to_element(ele).perform()
sleep(2)
driver.find_element(
    "css selector",
    "#s-user-setting-menu > div > a.setpref.first > span").click()
sleep(2)
driver.find_element(
    "css selector",
    "#se-setting-7 > a.prefpanelgo.setting-btn.c-btn.c-btn-primary").click()
sleep(2)
driver.switch_to.alert.accept()

sleep(2)
driver.quit() 
